#!/bin/bash

echo "========================================"
echo "Tesseract OCR 语言包下载脚本"
echo "========================================"

# 创建tessdata目录
if [ ! -d "tessdata" ]; then
    mkdir tessdata
fi
cd tessdata

echo "正在下载语言包文件..."

# 下载中文简体语言包
echo "下载中文简体语言包 (chi_sim.traineddata)..."
curl -L -o chi_sim.traineddata "https://github.com/tesseract-ocr/tessdata/raw/main/chi_sim.traineddata"

# 下载中文繁体语言包
echo "下载中文繁体语言包 (chi_tra.traineddata)..."
curl -L -o chi_tra.traineddata "https://github.com/tesseract-ocr/tessdata/raw/main/chi_tra.traineddata"

# 下载英文语言包
echo "下载英文语言包 (eng.traineddata)..."
curl -L -o eng.traineddata "https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata"

echo ""
echo "========================================"
echo "下载完成！"
echo "========================================"
echo "语言包文件已保存到 tessdata 目录："
echo "- chi_sim.traineddata (中文简体)"
echo "- chi_tra.traineddata (中文繁体)"
echo "- eng.traineddata (英文)"
echo ""
echo "现在可以重启应用服务测试OCR功能。" 